import http from '@/utils/http'


export const findCourseAPI = (...args) => {
  if (args.length === 1 && typeof args[0] === 'object') {
    const { pageNum, pageSize, orderBy, order, name } = args[0]
    return http({
      url: '/course/list',
      method: 'GET',
      params: { pageNum, pageSize, orderBy, order, name,status:0 }
    })
  } else if (args.length === 0) {
    return http({
      url: '/course/list',
      method: 'GET',
      params:{status:0}
    })
  } else {
    throw new Error('Invalid arguments')
  }
}
// export const findCourseAPI = ({ pageSize, current, orderBy, order, courname }) => {
//   let name=courname;
//     return http({
//       url:'/course/list',
//       method:'GET',
//       params:{
//         pageSize,
//         current,
//         orderBy,
//         order,
//         name,
//       }
//     })
//   }
//   export const findCourseAPI = () => {
//     return http({
//       url:'/course/list',
//       method:'GET',
//     })
//   }
export const findUserAPI = () => {

    return http({
      url: '/user/infoById',
      method: 'GET',
    })
  } 

export const updateUserAPI = (avatar,uname,gender,area,intro) => {
  // let name = uname
  // let sex = gender
  // let describe = intro
  // let address = area
  return http({
    url:'/user/updateInfo',
    method:'POST',
    data:{
      avatar:avatar,
      name:uname,
      sex:gender,
      describe:intro,
      address:area
    }
  })
}
export const teacherListAPI  = ()=>{
  return http({
    url:'/user/list',
    method:'GET',
    params:{
      role:'teacher',
      pageSize:8
    }
  })
}

export const findTeaInfo =(id)=>{
  return http({
    url:'/user/findById',
    method:'GET',
    params:{
      id:id
    }
  })
}